class Solution:
    def possibleStringCount(self, word: str) -> int:
        word += "#"
        cnt = {word[0]: 0}
        repeat = 0
        ans = 0
        for i, s in enumerate(word):
            if s in cnt:
                cnt[s] += 1
            else:
                if cnt[word[i - 1]] > 1:
                    ans += cnt[word[i - 1]]
                    repeat += 1
                cnt = {s: 1}
        if ans == 0: return 1
        if repeat >= 2: ans -= 1
        return ans


if __name__ == '__main__':
    s = Solution()
    r = s.possibleStringCount("abbcccc")
    print(r)
